// 通用分页响应结构
import type {Admin} from "@/types/auth.ts";

export interface PageInfo<T> {
    total: number;
    list: T[];
    pageNum: number;
    pageSize: number;
    size: number;
    startRow: number;
    endRow: number;
    pages: number;
    prePage: number;
    nextPage: number;
    isFirstPage: boolean;
    isLastPage: boolean;
    hasPreviousPage: boolean;
    hasNextPage: boolean;
    navigatePages: number;
    navigatepageNums: number[];
    navigateFirstPage: number;
    navigateLastPage: number;
}

export function defaultPageInfo<T>():PageInfo<T>{
    return {
        total: 0,
        list: [],
        pageNum: 1,
        pageSize: 10,
        size: 0,
        startRow: 0,
        endRow: 0,
        pages: 0,
        prePage: 0,
        nextPage: 0,
        isFirstPage: true,
        isLastPage: false,
        hasPreviousPage: false,
        hasNextPage: false,
        navigatePages: 5,
        navigatepageNums: [],
        navigateFirstPage: 1,
        navigateLastPage: 1,
    } as PageInfo<T>;
}


// 可扩展其他通用类型
export interface ApiResponse<T = unknown> {
    code: number;
    msg?: string;//可选
    data?: T //可选

    // 索引签名，支持任意额外字段，键类型字符串，值类型任意
    [key: string]: unknown;
}


//菜单类型
export interface Menu {
    id: number;
    menuName: string;
    parentId: number;
    sort: number;
    path: string;
    component: string;
    query: string;
    type: string;
    visible: boolean;
    stop: boolean;
    externalLink: boolean;
    perms: string;
    icon: string;
    createAdminId: number;
    createTime: string;
    updateTime: string;
    remake:string;
    children: Menu[];
    enable: boolean;
}
// 登录接口返回的数据结构
export interface LoginResponseData {
    msg: string;
    code: number;
    allowedMenuIds: number[]; // 明确为 number 数组
    permsList: string[];
    admin: Admin;
    menuTree: Menu[];
    token: string;
}